﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace idataplatform
{
    public partial class fhyhylist : Form
    {
        public fhyhylist()
        {
            InitializeComponent();
        }

        private void 条件查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fhyhysel form2 = new fhyhysel();
            form2.ShowDialog();
            if (form2.DialogResult == DialogResult.OK)
            {
                if (pubcls.fhydselSQL != "")
                {
                    conncls conns = new conncls();
                    dataGridView1.DataSource = conns.Dts(pubcls.fhydselSQL);
                    toolStripStatusLabel1.Text = dataGridView1.Rows.Count.ToString() + " 行" ;
                }
            }
        }

        private void 数据导出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExportExcel Et = new ExportExcel();
            Et.GridToExcel("招商蛇口佛山IPARK花园城非活跃会员数据", dataGridView1);
        }

        private void fhyhylist_Load(object sender, EventArgs e)
        {
            conncls conns = new conncls();
            //string fhydselSQL = "select a.hyno,a.phoneno,a.ctime,a.jf from (select hyno,phoneno,ctime,jf from hydetail_ipark where ctime <= '" + System.DateTime.Now.AddDays(-730).ToShortDateString() + "') a left join (SELECT HYNO, PHONENO, JFTIME FROM(select HYNO, PHONENO, JFTIME,ROW_NUMBER() OVER(PARTITION BY hyno ORDER BY jftime DESC) Num from jfchange_ipark where jfmark <> '新用户奖励积分' AND jfmark <> '测试' AND HYNO <> '') t WHERE t.Num >= 1) b on a.hyno = b.HYNO where b.hyno is null order by a.hyno asc;";
            string fhydselSQL = "select hyno,phoneno,ctime,jf from hydetail_ipark where ctime<='" + System.DateTime.Now.AddDays(-730).ToShortDateString() + "' and hyno not in (SELECT t2.HYNO FROM(SELECT t1.HYNO, t1.PHONENO, ROW_NUMBER() OVER(PARTITION BY t1.HYNO) Num FROM(SELECT HYNO, PHONENO FROM jfchange_ipark where jfmark <> '新用户奖励积分' AND jfmark <> '测试' AND HYNO <> '' UNION ALL SELECT HYNO, PHONENO FROM qhxtab_ipark where HYNO <> '') t1) t2 WHERE t2.Num = 1)";
            dataGridView1.DataSource = conns.Dts(fhydselSQL);
            toolStripStatusLabel1.Text = dataGridView1.Rows.Count.ToString() + " 行";
        }
    }
}
